<template>
  <div v-if="noticeList.length" class="noticeBar">
    <van-notice-bar scrollable left-icon="volume-o" :text="noticeList[0]?.noticeTitle" @click="toNotice" />
  </div>
</template>
<script setup>
import { getNoticeList } from "@/api/noticelist";
import { onMounted, ref } from "vue";

const noticeList = ref([]);
// 获取通知栏
const getNoticeListMethods = async () => {
  const res = await getNoticeList({
    page: 0,
    type: 1,
  });
  noticeList.value = res.data;
};
onMounted(() => {
  getNoticeListMethods();
});

const toNotice = () => {
  uni.navigateTo({ url: "/pages/noticeList/index" });
};
</script>
<style lang="less" scoped>
.noticeBar {
  margin-top: 24rpx;
}
</style>
